package demo;
abstract class Animal{
    public String name;
    public Animal(String name){
        this.name = name;
    }
}
interface IRunning{
    void run();
}
interface ISwimming{
    void swim();
}
interface IFly{
    void fly();
}
class Dog extends Animal implements IRunning{
    @Override
    public void run() {
        System.out.println(name+" 正在四条狗腿跑！");
    }

    public Dog(String name){
        super(name);
    }
}
class Fish extends Animal implements ISwimming{
    @Override
    public void swim() {
        System.out.println(name+" 正在游泳！");
    }
    public Fish(String name){
        super(name);
    }
}
class Bird extends Animal implements IFly {

    @Override
    public void fly() {
        System.out.println(name+" 正在飞！");
    }

    public Bird(String name) {
        super(name);
    }
}
class Duck extends Animal implements IRunning,ISwimming,IFly{
    @Override
    public void run() {
        System.out.println(name+" 正在用两条腿跑！");
    }

    @Override
    public void swim() {
        System.out.println(name+" 正在用两条腿游泳！");
    }

    @Override
    public void fly() {
        System.out.println(name +"正在用翅膀飞！");
    }

    public Duck(String name) {
        super(name);
    }
}
class Robot implements IRunning{
    @Override
    public void run() {
        System.out.println(" 机器人正在用机器腿跑！");
    }
}
public class Test {
    public static void walk(IRunning iRunning){
        iRunning.run();
    }
    public static void swim(ISwimming iSwimming){
        iSwimming.swim();
    }
    public static void main(String[] args) {
    walk(new Dog("旺财"));
    walk(new Duck("唐老鸭"));
    walk(new Robot());
    System.out.println("=======");
    swim(new Fish("七秒"));
    swim(new Duck("唐老鸭2号"));
    }
}
